import api, { type ResponseData } from '../index'
// 公众号的wxjssdk初始化
export const getWxInit = (data:{currentUrl:string}) =>
	api.get<{
		code:number,
		appId:string,
		timeStamp:string|number,
		nonceStr:string,
		signature:string,
		componentAppid:string
		domain?:string
	}>('system/api/weixin/JSSDKWxConfig', {
		data,
		custom: {
			auth: false
		}
	}
	)
// 公众号的授权登录初始化
export const getWxAppid = (data:{currentUrl:string}) =>
	api.get<{
		code:number,
		appId:string,
		componentAppid:string
	}>('system/api/weixin/JSSDKWxConfig/info', {
		data,
		custom: {
			auth: false
		}
	}
	)
// 公众号登录
export const postMpLogin = (data:{code:string,salt?:string}) =>
	api.post<ResponseData<{
		access_token?:string,
		openid?:string
	}>>('auth/api/customer/code/login',
		{
			data,
			custom: {
				auth: false
			}
		}
	)